
const app = getApp();
const DB = wx.cloud.database()
var that;
var util = require('../../utils/util');
var yun_file_id_arr = [];
var text = ''
Page({
  data: {
      inputVal: ""
  },
  onLoad(){
    that = this
  },
  qingkong(){
    this.setData({
      list2:false
    })
  },
  open2(e) {
    console.log('e', e)
    var _id = e.currentTarget.id
    wx.navigateTo({
      url: './filedetail?id=' + _id,
    })
  },
  see() {

    const db = wx.cloud.database()
    const school = DB.collection('learning_materials')
    school.where({
      text: {
        $regex: '.*' + text + '.*',
        $options: '1'
      }
    }).get({
      success: res => {
        console.log('匹配', res)
        if (res.data.length == 0) {
          wx.showModal({
            title: '提示',
            content: '暂时没找到对应答案',
            showCancel: false,
            success: function (res) { }
          })
          return;
        } else {
          that.setData({
            list2: res.data
          })
        }
      }
    })
  },

  input_p(e) {
    text = e.detail.value
  },

  onShow: function () {
   
    DB.collection('learning_materials').get().then(ress => {
      console.log('ressressressressressressressress',ress.data)
      
      this.setData({
        list:ress.data.reverse()
      })
    })
  },
});